package com.usdt.system.service.impl.cp;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usdt.system.domain.cp.ActivityImgEntity;
import com.usdt.system.mapper.cp.ActivityImgMapper;
import com.usdt.system.service.cp.ActivityImgService;

@Service
public class ActivityImgServiceImpl extends ServiceImpl<ActivityImgMapper, ActivityImgEntity> 
									implements ActivityImgService {

	@Override
	public List<ActivityImgEntity> list(Integer activityId, Byte type) {
		
		QueryWrapper<ActivityImgEntity> query = new QueryWrapper<ActivityImgEntity>();
		if(null!=activityId) {
			query.eq("activity_id", activityId);
		}
		if(null!=type) {
			query.eq("type", type);
		}
		List<ActivityImgEntity> list = baseMapper.selectList(query);
		if(CollectionUtils.isEmpty(list)) {
			list = new ArrayList<ActivityImgEntity>();
		}
		return list;
	}

	@Override
	public void insertList(List<ActivityImgEntity> List) {
		if(!CollectionUtils.isEmpty(List)) {
			for (ActivityImgEntity activityImgEntity : List) {
				baseMapper.insert(activityImgEntity);
			}
		}
	}

	@Override
	public void del(Integer activityId, Byte type) {
		QueryWrapper<ActivityImgEntity> query = new QueryWrapper<ActivityImgEntity>();
		query.eq("activity_id", activityId).eq("type", type);
		
		baseMapper.delete(query);
	}
	
	
}
